package org.csc.sss.core.security;

import org.csc.sss.core.model.SysUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

public class SecurityUser extends SysUser implements UserDetails {

    private transient List<GrantedAuthority> list;


    public SecurityUser(SysUser user, List<GrantedAuthority> authorities) {
        super.setId(user.getId());
        super.setNickname(user.getNickname());
        super.setPswd(user.getPswd());
        super.setEmail(user.getEmail());
        super.setStatus(user.getStatus());
        this.list = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.list;
    }

    @Override
    public String getPassword() {
        return super.getPswd();
    }

    @Override
    public String getUsername() {
        return super.getNickname();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public void setList(List<GrantedAuthority> list) {
        this.list = list;
    }

}
